package com.ibeeking.found.cop.b.rest.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.common.annotation.LoginUser;
import com.ibeeking.found.common.entity.CurrentUser;
import com.ibeeking.found.cop.b.rest.service.IGroupAutoTagsService;
import com.ibeeking.found.cop.b.rest.service.IGroupTagsClassService;
import com.ibeeking.found.cop.b.rest.service.IGroupTagsService;
import com.ibeeking.found.cop.service.common.param.*;
import com.ibeeking.found.cop.service.common.query.*;
import com.ibeeking.found.cop.service.common.vo.GroupAutoTagsVO;
import com.ibeeking.found.cop.service.common.vo.GroupTagsClassVO;
import com.ibeeking.found.cop.service.common.vo.GroupTagsVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName groupTagsController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/groupTags/v1")
public class groupTagsController {

    @Resource
    private IGroupTagsClassService groupTagsClassServiceImpl;

    @Resource
    private IGroupAutoTagsService groupAutoTagsServiceImpl;

    @Resource
    private IGroupTagsService groupTagsServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询群标签列表")
    @PostMapping(value = "/list")
    public List<GroupTagsClassVO> list(@RequestBody GroupTagsClassQuery query) {
        return groupTagsClassServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询群标签分页列表")
    @PostMapping(value = "/pageList")
    public Page<GroupTagsClassVO> pageList(@RequestBody GroupTagsClassPageQuery pageQuery) {
        return groupTagsClassServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "群批量设置标签")
    @PostMapping(value = "/changeTagsBatch")
    public Boolean changeTagsBatch(@RequestBody @Validated GroupTagsBatchParam param, @LoginUser CurrentUser currentUser) {
        return groupTagsServiceImpl.changeTagsBatch(param, currentUser);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加群标签")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) GroupTagsClassParam param) {
        return groupTagsClassServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改群标签")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) GroupTagsClassParam param) {
        return groupTagsClassServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/changeStatus/{id}/{status}")
    public Boolean changeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return groupTagsClassServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看群标签详情")
    @GetMapping(value = "/view/{id}")
    public GroupTagsClassVO view(@PathVariable("id") Long id) {
        return groupTagsClassServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除群标签")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return groupTagsClassServiceImpl.del(id);
    }

   // 自动标签

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询群自动标签列表")
    @PostMapping(value = "/autoTagsList")
    public List<GroupAutoTagsVO> autoTagsList(@RequestBody GroupAutoTagsQuery query) {
        return groupAutoTagsServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询群自动标签分页列表")
    @PostMapping(value = "/autoTagsPageList")
    public Page<GroupAutoTagsVO> autoTagsPageList(@RequestBody GroupAutoTagsPageQuery pageQuery) {
        return groupAutoTagsServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加群自动标签")
    @PostMapping(value = "/autoTagsAdd")
    public Boolean autoTagsAdd(@RequestBody @Validated(BaseValidationGroup.Insert.class) GroupAutoTagsParam param) {
        return groupAutoTagsServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改群自动标签")
    @PostMapping(value = "/autoTagsModify")
    public Boolean autoTagsModify(@RequestBody @Validated(BaseValidationGroup.Update.class) GroupAutoTagsParam param) {
        return groupAutoTagsServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/autoTagsChangeStatus/{id}/{status}")
    public Boolean autoTagsChangeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return groupAutoTagsServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看群自动标签详情")
    @GetMapping(value = "/autoTagsView/{id}")
    public GroupAutoTagsVO autoTagsView(@PathVariable("id") Long id) {
        return groupAutoTagsServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除群自动标签")
    @GetMapping(value = "/autoTagsDel/{id}")
    public Boolean autoTagsDel(@PathVariable("id") Long id) {
        return groupAutoTagsServiceImpl.del(id);
    }

}
